package com.sz.biz.trade.goods.service.impl;

import com.sz.biz.trade.goods.entity.GoodsProjectRel;
import com.sz.biz.common.AbstractVersionEntityService;
import com.sz.biz.trade.goods.service.GoodsProjectRelService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Function: 商品项目服务<br>
 * Author: jifeixing <br>
 * Date: 2017-07-12 14:10:00
 */
@Service("goodsProjectRelService")
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public class GoodsProjectRelServiceImpl extends AbstractVersionEntityService implements GoodsProjectRelService {

    @Override
    protected String getMapperNamespace() {
        return "GoodsProjectRelMapper";
    }

    /**
     * 添加项目限制
     * @param goodsProjectRel
     * @return
     */
    @Override
    public void save(GoodsProjectRel goodsProjectRel) {
        dao.save(getSqlName("insertSelective"), goodsProjectRel);
    }
    /**
     * 项目限制id
     * @param goodsId
     * @return
     */
    @Override
    public List<Integer> findProjectIdsByGoodsId(Integer goodsId) {
        return dao.findForList(getSqlName("findProjectIdsByGoodsId"), goodsId, Integer.class);
    }
    /**
     * 根据商品id删除
     * @param goodsId
     */
    @Override
    public void deleteByGoodsId(Integer goodsId) {
        dao.delete(getSqlName("deleteByGoodsId"), goodsId);
    }
}
